var t = require;
var e = module;
var o = exports;
var i, n = this && this.__extends || (i = function(t, e) {
    return (i = Object.setPrototypeOf || {
        __proto__: []
    }
    instanceof Array &&
    function(t, e) {
        t.__proto__ = e
    } ||
    function(t, e) {
        for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o])
    })(t, e)
},
function(t, e) {
    function o() {
        this.constructor = t
    }
    i(t, e),
    t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o)
}),
a = this && this.__decorate ||
function(t, e, o, i) {
    var n, a = arguments.length,
    r = a < 3 ? e: null === i ? i = Object.getOwnPropertyDescriptor(e, o) : i;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, i);
    else for (var s = t.length - 1; s >= 0; s--)(n = t[s]) && (r = (a < 3 ? n(r) : a > 3 ? n(e, o, r) : n(e, o)) || r);
    return a > 3 && r && Object.defineProperty(e, o, r),
    r
};
Object.defineProperty(o, "__esModule", {
    value: !0
});
var r = t("GlobalUserData"),
s = t("Hint"),
l = t("Util"),
c = t("Bounce"),
d = t("Global"),
h = t("HallConstant"),
p = t("ChampionManager"),
u = cc._decorator,
f = u.ccclass,
m = u.property,
_ = function(t) {
    function e() {
        var e = null !== t && t.apply(this, arguments) || this;
        return e.portraitSpr = null,
        e.powerLabel = null,
        e.nameLabel = null,
        e.spr_corne = null,
        e.frame_icon_Arr = new Array,
        e._gameControl = null,
        e._gameArenaControl = null,
        e._gameLogic = null,
        e.rEquipBodyData = null,
        e.rEquipWheelData = null,
        e.rEquipWeaponData = null,
        e.rEquipToolsData = null,
        e._data = null,
        e._replaceIndex = 0,
        e
    }
    return n(e, t),
    e.prototype.initViewData = function(t, e, o, i, n, a, r, s) {
        void 0 === r && (r = !1),
        void 0 === s && (s = 0),
        this._data = i,
        this._isAdd = a,
        this._isReplace = r,
        this._replaceIndex = s,
        this.loadHeadSprite(i.headUrl),
        this._gameControl = t,
        this._gameArenaControl = e,
        this._gameLogic = o,
        this.nameLabel.string = i.name,
        this.node.parent = n,
        this.node.setPosition(cc.v2(0, -68.525)),
        this.node.scale = 0;
        var l = cc.v3(i.pos.x, i.pos.y);
        this.spr_corne.spriteFrame = this.frame_icon_Arr[i.star - 1],
        cc.tween(this.node).to(1, {
            position: l,
            scale: 1
        },
        {
            easing: "elasticOut"
        }).start(),
        this.initData()
    },
    e.prototype.initData = function() {
        cc.log("nGameGrade:" + r.default.nGameGrade);
        for (var t, e = 0,
        o = 0; o < r.default.nEquipMax; o++) l.Util.getBodyData(r.default.curEquipBody[o]) && e++;
        switch (this._data.star) {
            case 1:
                t = e;
            break;
            case 2:
                t = e < 3 ? 2 : 3;
            break;
            case 3:
                t = 3;
        }
        var i = this._gameLogic.getArenaCarData(t, this._data.star);
        this.rEquipBodyData = i.body,
        this.rEquipWheelData = i.wheel,
        this.rEquipWeaponData = i.weapon,
        this.rEquipToolsData = i.tools,
        this.setRare(this.rEquipBodyData);
        var n = l.Util.getCurItemPower(i);
        this._isReplace ? (cc.log("替换"), this._data.power = n, this.powerLabel.node.addComponent(c.default).init(1, this._data.power, "战力:", !0), r.default.saveArenaModeData(this._isAdd, this._data, this._isReplace, this._replaceIndex)) : this._isAdd ? (cc.log("添加"), this._data.power = n, this.powerLabel.node.addComponent(c.default).init(1, this._data.power, "战力:", !0), r.default.saveArenaModeData(this._isAdd, this._data)) : this.powerLabel.node.addComponent(c.default).init(1, this._data.power, "战力:")
    },
    e.prototype.addEventListener = function() {
        this.node.on(cc.Node.EventType.TOUCH_START, this.onStartGame.bind(this))
    },
    e.prototype.setRare = function(t) {
        for (var e = 0; e < t.length; e++) l.Util.probability(.25) && (t[e].quality = d.Quality.epic)
    },
    e.prototype.onStartGame = function() {
        var t = this;
        r.default.vitData.num < h.Vit_Game_Num ? s.default.show("体力不足") : (r.default.enemyTrophy = p.default.Ins.getETrophy(), console.log("onStartGame"), this.node.off(cc.Node.EventType.TOUCH_START), r.default.nCurArenaOpponentData = this._data, r.default.saveVitData(!1, 5), s.default.showConsume(this.node, d.ConsumeType.Vit, 5), this._gameArenaControl.selected(this.node), cc.tween(this.node).to(.8, {
            position: cc.v3(0, -68.525)
        },
        {
            easing: "elasticOut"
        }).delay(.2).call(function() {
            t._gameControl.initRightData(t.rEquipBodyData, t.rEquipWheelData, t.rEquipWeaponData, t.rEquipToolsData),
            t._gameControl.setRightInfo(t.nameLabel.string, t.portraitSpr.spriteFrame),
            t._gameControl.onBtnGameStart(),
            t._gameArenaControl.node.destroy()
        }).start())
    },
    e.prototype.loadHeadSprite = function(t) {
        var e = this;
        cc.assetManager.loadBundle("Role",
        function(o, i) {
            if (o) return cc.error(o);
            cc.log("load resources subpackage (Role) successfully."),
            i.load(t, cc.SpriteFrame,
            function(t, o) {
                if (t) return cc.error(t);
                o && (e.portraitSpr.spriteFrame = o),
                cc.log("loadHeadSprite:" + o.name)
            })
        })
    },
    a([m(cc.Sprite)], e.prototype, "portraitSpr", void 0),
    a([m(cc.Label)], e.prototype, "powerLabel", void 0),
    a([m(cc.Label)], e.prototype, "nameLabel", void 0),
    a([m(cc.Sprite)], e.prototype, "spr_corne", void 0),
    a([m([cc.SpriteFrame])], e.prototype, "frame_icon_Arr", void 0),
    a([f], e)
} (cc.Component);
o.default = _